/* eslint valid-jsdoc: "off" */

'use strict';

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
	/**
	 * built-in config
	 * @type {Egg.EggAppConfig}
	 **/
	const config = exports = {};

	// use for cookie sign key, should change to your own and keep security
	config.keys = appInfo.name + '_1556588986317_6984';

	// add your middleware config here
	config.middleware = [];

	// 自定义端口
	config.cluster = {
		listen: {
			port: 7001
		}
	};

	config.sequelize = {
		dialect: 'mysql',
		host: '127.0.0.1',
		port: 3306,
		database: 'dev',
		username: 'root',
		password: '',
		timezone: "+08:00",
	};

	exports.validate = {
		// convert: false,
		// validateRoot: false,
	};

	//csrf 配置
	exports.security = {
		csrf: {
			// queryName: '_csrf', // 通过 query 传递 CSRF token 的默认字段为 _csrf
			// bodyName: '_csrf', // 通过 body 传递 CSRF token 的默认字段为 _csrf
			// headerName: 'x-csrf-token', // 通过 header 传递 CSRF token 的默认字段为 x-csrf-token
			enable: false,
			ignoreJSON: true
		},
		// 白名单
		domainWhiteList: ['http://127.0.0.1:7001']
	};

	// egg-cors 配置
	exports.cors = {
		origin: '*',
		allowMethods: 'GET,HEAD,PUT,POST,DELETE,PATCH,OPTIONS',
		credentials: true
	};

	// add your user config here
	const userConfig = {
		// myAppName: 'egg',
	};

	return {
		...config,
		...userConfig,
	};
};
